package com.haozhen.demo

/**
  * @author haozhen
  * @email haozh@ync1.com
  * @date 2021/2/8  1:02
  */
object WordCountScalaStream {

  def main(args: Array[String]): Unit = {
    import org.apache.flink.streaming.api.scala._
    val environment: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment


    val ds1: DataStream[String] = environment.socketTextStream("localhost",9999)

    val result: DataStream[(String, Int)] = ds1.flatMap(_.split(" ")).map((_,1)).keyBy(0).sum(1)

    result.print()

    environment.execute()
  }
}
